package com.example.demo.event.base;

import org.springframework.context.ApplicationEvent;
import java.io.Serializable;

/**
 * 事件对象包装器
 */
public class Event<T extends Serializable> extends ApplicationEvent {

	private static final long serialVersionUID = 2921527144650691457L;

	public Event(T source) {
        super(new EventSource<>(source));
    }

    public Event(T source, String action) {
        super(new EventSource<>(source, action));
    }

    public void publish() {
        AppContext.getContext().publishEvent(this);
    }
}
